package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	lamps
*/
public class lamps {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("lamps.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"lamps.out")));
		new lamps().solve(f, out);
		out.close();
		System.exit(0);
	}
	
	private int N;
	private int C;
	private int[] on;
	private int[] off;
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		N = read(f);
		C = read(f);
		on = read2(f);
		off = read2(f);
		
		int[] lamp = new int[N];
		ArrayList<String> res = new ArrayList<String>(); 
		
		for (int a1=0; a1<2; a1++) {
			for (int a2=0; a2<2; a2++) {
				for (int a3=0; a3<2; a3++) {
					for (int a4=0; a4<2; a4++) {
						int c = C - a1 - a2 - a3 - a4;
						if (c<0 || c%2!=0) continue;
						
						for (int i=0; i<N; i++) lamp[i] = 1;
						op1(lamp, a1);
						op2(lamp, a2);
						op3(lamp, a3);
						op4(lamp, a4);
						
						boolean pass = true;
						for (int i : on) {
							if (lamp[i-1] == 0) {
								pass = false;
								break;
							}
						}
						if (!pass) continue;
						
						for (int i : off) {
							if (lamp[i-1] == 1) {
								pass = false;
								break;
							}
						}
						if (!pass) continue;
						
						StringBuilder sb = new StringBuilder();
						for (int i : lamp) {
							sb.append(i);
						}
						res.add(sb.toString());
					}
				}
			}
		}
		
		Collections.sort(res);
		for (String s : res) out.println(s);
		if (res.size() == 0) out.println("IMPOSSIBLE");
	}
	
	private void op1(int[] lamp, int a) {
		if (a == 1) {
			for (int i=0; i<N; i++) lamp[i] = 1 - lamp[i];
		}
	}
	
	private void op2(int[] lamp, int a) {
		for (int i=0; i<N; i+=2) {
			lamp[i] = a==0? lamp[i] : 1 - lamp[i];
		}
	}
	
	private void op3(int[] lamp, int a) {
		for (int i=1; i<N; i+=2) {
			lamp[i] = a==0? lamp[i] : 1 - lamp[i];
		}
	}
	
	private void op4(int[] lamp, int a) {
		for (int i=0; i<N; i+=3) {
			lamp[i] = a==0? lamp[i] : 1 - lamp[i];
		}
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	public int[] read2(BufferedReader f) throws IOException {
		String[] t = f.readLine().split(" ");
		int[] a = new int[t.length-1];
		for (int i=0; i<t.length-1; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
		return a;
	}
}
